from itertools import permutations, product
from fractions import Fraction
import math

def calc_24_points(numbers):
    """
    Find all valid arithmetic expressions using exactly four natural numbers (1-13)
    that evaluate to 24 using +, -, *, / and parentheses.
    
    Args:
        numbers (list): List of four natural numbers (1-13)
        
    Returns:
        list: List of strings representing valid expressions
    """
    operations = ['+', '-', '*', '/']
    valid_expressions = []
    
    # Try all permutations of numbers
    for nums in permutations(numbers):
        # Try all possible combinations of operations
        for ops in product(operations, repeat=3):
            # Test different parenthesis placements
            results = []
            
            # Pattern 1: ((a op1 b) op2 c) op3 d
            expr1 = f"(({nums[0]}{ops[0]}{nums[1]}){ops[1]}{nums[2]}){ops[2]}{nums[3]}"
            try:
                if abs(eval(expr1) - 24) < 1e-10:
                    results.append(expr1)
            except ZeroDivisionError:
                pass
            
            # Pattern 2: (a op1 (b op2 c)) op3 d
            expr2 = f"({nums[0]}{ops[0]}({nums[1]}{ops[1]}{nums[2]})){ops[2]}{nums[3]}"
            try:
                if abs(eval(expr2) - 24) < 1e-10:
                    results.append(expr2)
            except ZeroDivisionError:
                pass
            
            # Pattern 3: a op1 ((b op2 c) op3 d)
            expr3 = f"{nums[0]}{ops[0]}(({nums[1]}{ops[1]}{nums[2]}){ops[2]}{nums[3]})"
            try:
                if abs(eval(expr3) - 24) < 1e-10:
                    results.append(expr3)
            except ZeroDivisionError:
                pass
            
            # Pattern 4: a op1 (b op2 (c op3 d))
            expr4 = f"{nums[0]}{ops[0]}({nums[1]}{ops[1]}({nums[2]}{ops[2]}{nums[3]}))"
            try:
                if abs(eval(expr4) - 24) < 1e-10:
                    results.append(expr4)
            except ZeroDivisionError:
                pass
            
            # Pattern 5: (a op1 b) op2 (c op3 d)
            expr5 = f"({nums[0]}{ops[0]}{nums[1]}){ops[1]}({nums[2]}{ops[2]}{nums[3]})"
            try:
                if abs(eval(expr5) - 24) < 1e-10:
                    results.append(expr5)
            except ZeroDivisionError:
                pass
            
            # Remove duplicates while preserving order
            unique_results = []
            for r in results:
                if r not in unique_results:
                    unique_results.append(r)
            
            valid_expressions.extend(unique_results)
    
    # Remove duplicates and sort for consistent output
    return sorted(list(set(valid_expressions)))

# Test code
if __name__ == "__main__":
    test_numbers = [7, 11, 3, 10]
    results = calc_24_points(test_numbers)
    
    print(f"Found {len(results)} valid expressions for {test_numbers}:")
    for expr in results:
        try:
            result = eval(expr)
            print(f"{expr} = {result}")
        except:
            print(f"{expr} = Error")

    # Verify all results are correct
    print("\nVerifying results:")
    for expr in results:
        try:
            assert abs(eval(expr) - 24) < 1e-10, f"Expression {expr} does not equal 24"
            print(f"✓ {expr}")
        except Exception as e:
            print(f"✗ {expr} - {str(e)}")
